<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%-- JSTL表达式（判断，循环，输出） --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%-- 方法表达式（字符串截取，替换） --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>

	<head>
		<base href="<%=basePath%>">
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>地址管理</title>

		<link href="<%=basePath%>css/admin.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" href="<%=basePath%>css/amazeui.min.css">
		<link rel="stylesheet" href="<%=basePath%>css/wap.css?2">
		<link href="<%=basePath%>css/personal.css" rel="stylesheet" type="text/css">
		<link href="<%=basePath%>css/addstyle.css?v=1" rel="stylesheet" type="text/css">
		<script src="<%=basePath%>js/jquery.min.js"></script>
		<script src="<%=basePath%>js/amazeui.min.js"></script>
		<script src="<%=basePath%>js/jquery.ld.js"></script>
		<script src="<%=basePath%>js/areaAdd.js"></script>
		<script src="<%=basePath%>js/check.js?v=1"></script>
		<script>
			function edit(expressId){
				$.ajaxSetup({
					async : false
				});
				$.post("<%=basePath%>order/getExpress", {expressId: expressId}, function(data){
					$("#doc-modal-1").html(data);
				});
			}

			function delClick(expressId){
				if(window.confirm("确认删除吗？")){
					$.post("<%=basePath%>order/deleteExpress", {expressId: expressId}, function (res) {
						if(res.code == 1){
							window.location.reload();
						}else{
							alert(res.message);
						}
					});
				}
			}

			function openAdd(){
				$('#doc-modal-1').show();
			}

			function closeAdd(){
				$('#doc-modal-1').hide();
				$(".am-dimmer.am-active").remove();
			}
		</script>
	</head>

	<body>
		<div class="pet_mian" id="top">
			<div class="pet_head">
				<header data-am-widget="header"
						class="am-header am-header-default pet_head_block">
					<div class="am-header-left am-header-nav ">
						<a href="javascript:;" class="iconfont pet_head_jt_ico" onclick="window.location.href='<%=basePath%>${returnUrl}'">&#xe601;</a>
					</div>
					<div class="pet_news_list_tag_name">地址管理</div>
				</header>
			</div>
			<!--地址 -->
			<div class="center" style="padding-top: 60px;">
				<div class="col-main">
					<div class="main-wrap" style="margin-left: 0;">

						<div class="user-address">
							<ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">
								<c:forEach var="express" items="${expressList}">
									<li class="user-addresslist <c:if test="${express.defaultFlag == '1'}">defaultAddr</c:if>">
										<span class="new-option-r" data-id="${express.expressId}"><i class="am-icon-check-circle"></i>默认地址</span>
										<p class="new-tit new-p-re">
											<span class="new-txt">${express.name}</span>
											<span class="new-txt-rd2">${express.mobile}</span>
										</p>
										<div class="new-mu_l2a new-p-re">
											<p class="new-mu_l2cw">
												<span class="title">地址：</span>
												<span>${express.areaName}</span>
												<%--<span class="province">湖北</span>省
												<span class="city">武汉</span>市
												<span class="dist">洪山</span>区
												<span class="street">雄楚大道666号(中南财经政法大学)</span></p>--%>
										</div>
										<div class="new-addr-btn">
											<a href="javascript:;" id="edit" onclick="edit(${express.expressId})" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}"><i class="am-icon-edit"></i>编辑</a>
											<span class="new-addr-bar">|</span>
											<a href="javascript:void(0);" onclick="delClick(${express.expressId});"><i class="am-icon-trash"></i>删除</a>
										</div>
									</li>
								</c:forEach>
							</ul>
							<div class="clear"></div>
							<a href="javascript:;" class="new-abtn-type" onclick="edit(null)" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
							<!--例子-->
							<div class="am-modal am-modal-no-btn" id="doc-modal-1" style="padding-top: 60px;">

							</div>

						</div>

						<script type="text/javascript">
							$(document).ready(function() {
								$(".new-option-r").click(function() {
									$(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
									$.post("<%=basePath%>user/defaultExpress", {expressId: $(this).data('id')}, function (res) {
										if(res.code != 1){
											alert(res.message);
										}
									});
								});

								var $ww = $(window).width();
								if($ww>640) {
									$("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
								}
							})
						</script>
						<div class="clear"></div>
					</div>
			</div>
		</div>
	</div>
	</body>

</html>